package code

type Err int

var (
	UNKNOW       = Err(0)
	SUCCESS      = Err(200)
	FORBIDDEN    = Err(403)
	NOTFOUND     = Err(404)
	INTERNAL_ERR = Err(500)
	// 参数校验
	PARAMETER_ERR = Err(10000)
	// jenkins 相关
	JENKINS_INIT_FAIL = Err(10001)

	// project
	CREATE_FAIL = Err(11000)
	DELETE_FAIL = Err(11001)
	UPDATE_FAIL = Err(11002)
	SELECT_FAIL = Err(11003)

	// job
	GET_JOBS_ERR   = Err(13000)
	DELETE_JOB_ERR = Err(13001)
	CREATE_JOB_ERR = Err(13002)
	UPDATE_JOB_ERR = Err(13003)

	// build
	BUILD_NOT_FOUND = Err(12000)
	BUILD_FAIL      = Err(12001)
	STOP_BUILD_FAIL = Err(12002)
	GET_INFO_ERR    = Err(12003)
	GET_STAGE_ERR   = Err(12004)
	// conversion
	CONVERSION_FAIL = Err(13000)
	OPENAPI_FAIL    = Err(13001)

	// git
	CONNECT_FAIL = Err(14001)
)

// 全局错误码
var ErrMsg = map[Err]string{
	UNKNOW:        "未知错误",
	SUCCESS:       "请求成功",
	FORBIDDEN:     "用户未认证",
	NOTFOUND:      "无效路由",
	INTERNAL_ERR:  "服务器内部错误",
	PARAMETER_ERR: "请求参数错误",

	JENKINS_INIT_FAIL: "jenkins init 失败",

	CREATE_FAIL: "创建失败",
	DELETE_FAIL: "删除失败",
	UPDATE_FAIL: "更新失败",
	SELECT_FAIL: "查询失败",

	GET_JOBS_ERR:   "获取 Jobs 出错",
	DELETE_JOB_ERR: "删除失败",
	CREATE_JOB_ERR: "创建失败",
	UPDATE_JOB_ERR: "更新失败",

	BUILD_NOT_FOUND: "build 未找到",
	BUILD_FAIL:      "启动构建失败",
	STOP_BUILD_FAIL: "中止构建失败",
	GET_INFO_ERR:    "获取信息失败",
	GET_STAGE_ERR:   "获取构建步骤失败",

	CONVERSION_FAIL: "转换失败",
	OPENAPI_FAIL:    "open api 请求失败",
	CONNECT_FAIL:    "git 仓库连接失败",
}
